<template>
  <div class="notice">
    <div class="title">
      <span>{{ title }}</span>
      <span class="more" @click="goMore(type)">更多 ></span>
    </div>
    <div class="notice-info">
      <div v-for="item in noticeList" :key="item.id" class="list-item">
        <div class="left">
          <div class="month-year">
            <div class="month">{{ item.createTime.substring(5, 10) }}</div>
            <div class="yeah">{{ item.createTime.substring(0, 4) }}</div>
          </div>
          <div class="notice-title" :title="item.noticeTitle">{{ item.noticeTitle }}</div>
        </div>

        <i class="el-icon-caret-right" style="font-size: 16px; cursor: pointer" @click="goDetail(item)"></i>
      </div>
    </div>
    <!-- 预览弹窗 -->
    <announcement-info ref="announcementInfoCom"></announcement-info>
  </div>
</template>
<script>
  import AnnouncementInfo from './announcementInfo.vue'

  export default {
    components: { AnnouncementInfo },
    props: {
      title: {
        type: String,
        default: ''
      },
      type: {
        type: String,
        default: '2'
      },
      list: {
        type: Array,
        default: () => []
      }
    },
    data() {
      return {
        noticeList: []
      }
    },
    watch: {
      list: {
        handler(arr) {
          this.noticeList = arr
        },
        deep: true,
        immediate: true
      }
    },
    created() {},
    mounted() {},
    methods: {
      // 更多
      goMore() {
        this.$router.push({
          path: '/notice',
          query: { type: this.type }
        })
      },
      // 详情
      goDetail(info) {
        this.$refs.announcementInfoCom.handleOpen(info)
      }
    }
  }
</script>
<style lang="scss" scoped>
  .notice {
    .title {
      height: 36px;
      font-size: 26px;
      font-family: PingFang SC-Medium, PingFang SC;
      font-weight: 500;
      color: #000000;
      line-height: 30px;
      margin-bottom: 24px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      .more {
        height: 20px;
        font-size: 12px;
        font-family: PingFang SC-Regular, PingFang SC;
        font-weight: 400;
        color: #757575;
        line-height: 20px;
        cursor: pointer;
      }
    }
    .notice-info {
      background: #fff;
      padding: 12px 30px 24px;
      box-shadow: 0px 4px 20px 0px rgba(0, 0, 0, 0.06);
      border-radius: 0px 0px 0px 0px;
      opacity: 1;
      height: 296px;
      box-sizing: border-box;
      overflow: hidden;
    }
    .list-item {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 12px 0;
      border-bottom: 1px dashed #e0e0e0;
      .notice-title {
        height: 20px;
        font-size: 16px;
        font-family: PingFang SC-Medium, PingFang SC;
        font-weight: 500;
        color: #333333;
        line-height: 20px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        width: calc(100% - 100px);
        cursor: pointer;
      }
      .left {
        width: calc(100% - 16px);
        display: flex;
        align-items: center;
      }
      .month-year {
        padding-right: 20px;
        border-right: 1px solid #e0e0e0;
        margin-right: 20px;
        width: 44px;
      }
      .month {
        font-size: 14px;
        font-family: PingFang SC-Semibold, PingFang SC;
        font-weight: 600;
        color: #757575;
      }
      .year {
        font-size: 12px;
        font-family: PingFang SC-Regular, PingFang SC;
        font-weight: 400;
        color: #757575;
      }
    }
  }
</style>
